<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <%--<c:set var="ctx" value="${pageContext.request.contextPath}"/>--%>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>添加客户付款账户</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <form id="addOrUpdBankInfoForm">
        <input type="hidden" id="paySchId" name="paySchId" value="${paySchId}"/>
        <input type="hidden" id="bankId" name="bankId" value="${bank.id}"/>
        <input type="hidden" id="paySchDId" name="paySchDId" value="${paySchDId}"/>
        <%--客户付款账户--%>
        <c:if test="${bindType==1}">
        <div class="fieldset1 tabel_col clearFix">
            <div class="fieldBox col_50">
                <div class="label"><span class="requiredSymbol">*</span>付款银行</div>
                <div class="field">
                    <input class="ui-textbox" id="bankNm" name="bankNm" value="${bank.bankNm}" validate="{required:true,stringMaxLength:80}">
                </div>
            </div>
            <div class="fieldBox col_50">
                <div class="label"><span class="requiredSymbol">*</span>付款账户</div>
                <div class="field">
                    <input type="text" id="accNm" name="accNm" class="ui-textbox" value="${bank.accNm}" validate="{required:true,stringMaxLength:80}"/>
                </div>
            </div>
            <div class="fieldBox col_50">
                <div class="label"><span class="requiredSymbol">*</span>付款账号</div>
                <div class="field">
                    <input type="text" id="accNo" name="accNo" class="ui-textbox" value="${bank.accNo}" validate="{required:true,number:true,stringMaxLength:30}"/>
                </div>
            </div>
            <div class="fieldBox col_50">
                <div class="label"><span class="requiredSymbol">*</span>付款金额</div>
                <div class="field">
                    <input type="text" id="payAmt" name="payAmt" class="ui-textbox" value="${bank.payAmt==null?null:bank.payAmt/100}" validate="{required:true,amount:true}"/>
                </div>
            </div>
            <div class="fieldBox col_50">
                <div class="label"><span class="requiredSymbol">*</span>付款时间</div>
                <div class="field">
                    <input name="payTm" id="payTm" type="text" class="ui-datepicker" value="<fmt:formatDate value="${bank.payTm}" pattern="yyyy-MM-dd"/>" validate="{required:true}">
                </div>
            </div>
            <div class="fieldBox col_50">
                <div class="label"></div>
                <div class="field">
                </div>
            </div>
            <div class="fieldBox col_100">
                <div class="label">备注</div>
                <div class="field">
                    <textarea name="bankRem" id="bankRem" rows="4" class="" style="width:98%" maxlength="200">${bank.bankRem}</textarea>
                </div>
            </div>
            <div class="fieldBox col_100">
                <div class="label">注:</div>
                <div class="field">
                    <span name="" id="" style="color: red;">注意：请务必在备注信息中，填写打款资金可使用金额信息，否则财务将按照来款全额分解</span>
                </div>
            </div>
        </div>
        <div class="btnsBox clearFix" style="text-align: center">
            <span id="saveBtn" class="sq-button sq-button-round" onclick="saveBankInfo(${bindType});">保存</span>
        </div>
        </c:if>

        <%--客户收款账户--%>
        <c:if test="${bindType==2 || bindType==5}">
            <div class="fieldset1 tabel_col clearFix">
                <div class="fieldBox col_100_auto">
                    <div class="label"><span class="requiredSymbol">*</span>收款银行</div>
                    <div class="field">
                        <input class="ui-textbox" id="bankNm" name="bankNm" value="${bank.bankNm}" validate="{required:true,stringMaxLength:80}">
                    </div>
                </div>
                <div class="fieldBox col_100_auto">
                    <div class="label"><span class="requiredSymbol">*</span>收款账户</div>
                    <div class="field">
                        <input type="text" id="accNm" name="accNm" class="ui-textbox" value="${bank.accNm}" validate="{required:true,stringMaxLength:80}"/>
                    </div>
                </div>
                <div class="fieldBox col_100_auto">
                    <div class="label"><span class="requiredSymbol">*</span>收款账号</div>
                    <div class="field">
                        <input type="text" id="accNo" name="accNo" class="ui-textbox" value="${bank.accNo}" validate="{required:true,number:true,stringMaxLength:30}"/>
                    </div>
                </div>
                <div class="fieldBox col_100_auto">
                    <div class="label"><span class="requiredSymbol">*</span>证件号码</div>
                    <div class="field">
                        <input type="text" id="identityNo" name="identityNo" class="ui-textbox" value="${bank.identityNo}" validate="{required:true,stringMaxLength:20}"/>
                    </div>
                </div>
                <div class="fieldBox col_100_auto">
                    <div class="label"><span class="requiredSymbol">*</span>预留手机号</div>
                    <div class="field">
                        <input type="text" id="actTel" name="actTel" class="ui-textbox" value="${bank.actTel}" validate="{required:true,number:true,stringMaxLength:11}" maxlength="11"/>
                    </div>
                </div>
                <div class="fieldBox col_100_auto">
                    <div class="label">
                        <c:if test="${bindType==5}">
                            <span class="requiredSymbol">*</span>
                        </c:if>
                        开户行行号</div>
                    <div class="field">
                        <input type="text" id="bankNo" name="bankNo" class="ui-textbox" value="${bank.bankNo}" <c:if test="${bindType==5}">validate="{required:true,number:true}"</c:if>  />
                    </div>
                </div>
                <div class="fieldBox col_100_auto">
                    <div class="label">
                        <c:if test="${bindType==5}">
                            <span class="requiredSymbol">*</span>
                        </c:if>
                        开户行支行</div>
                    <div class="field">
                        <input type="text" id="branchBank" name="branchBank" class="ui-textbox" value="${bank.branchBank}" <c:if test="${bindType==5}">validate="{required:true}"</c:if> />
                    </div>
                </div>
                <div class="fieldBox col_100">
                    <div class="label">备注</div>
                    <div class="field">
                        <textarea name="bankRem" id="bankRem" rows="4" class="" style="width:98%" maxlength="200">${bank.bankRem}</textarea>
                    </div>
                </div>
                <div class="fieldBox col_100">
                    <div class="label">注:</div>
                    <div class="field">
                        <span name="" id="" style="color: red;">注意：仅支持对私账户，请反复核查收款账号，账号错误导致退款失败需自行承担</span>
                    </div>
                </div>
            </div>
            <div class="btnsBox clearFix" style="text-align: center">
                <span id="saveBtn" class="sq-button sq-button-round" onclick="saveBankInfo(${bindType});">保存</span>
            </div>
        </c:if>

        <%--我司付款账户--%>
        <c:if test="${bindType==3}">
            <div class="fieldset1 tabel_col clearFix">
                <div class="fieldBox col_100_auto">
                    <div class="label"><span class="requiredSymbol">*</span>付款银行</div>
                    <div class="field">
                        <input class="ui-textbox" id="bankNm" name="bankNm" value="${bank.bankNm}" validate="{required:true,stringMaxLength:80}">
                    </div>
                </div>
                <div class="fieldBox col_100_auto">
                    <div class="label"><span class="requiredSymbol">*</span>付款账号</div>
                    <div class="field">
                        <input type="text" id="accNo" name="accNo" class="ui-textbox" value="${bank.accNo}" validate="{required:true,number:true,stringMaxLength:30}"/>
                    </div>
                </div>
                <div class="fieldBox col_100_auto">
                    <div class="label"><span class="requiredSymbol">*</span>付款金额</div>
                    <div class="field">
                        <input type="text" id="payAmt" name="payAmt" class="ui-textbox" value="${bank.payAmt==null?null:bank.payAmt/100}" validate="{required:true,amount:true}"/>
                    </div>
                </div>
            
            <c:if test="${not empty insCode}">
                <div class="fieldBox col_100_auto">
                    <div class="label"><span class="requiredSymbol">*</span>付款时间</div>
                    <div class="field">
                        <input name="payTm" id="payTm" type="text" class="ui-datepicker" value="<fmt:formatDate value="${bank.payTm}" pattern="yyyy-MM-dd"/>" validate="{required:true}">
                    </div>
                </div>
            </c:if>

                <div class="fieldBox col_100">
                    <div class="label">备注</div>
                    <div class="field">
                        <textarea name="bankRem" id="bankRem" rows="4" class="" style="width:98%" maxlength="200">${bank.bankRem}</textarea>
                    </div>
                </div>
            </div>
            <div class="btnsBox clearFix" style="text-align: center">
                <input type="text" style="display: none;" id="insCode" name="insCode" value="${insCode}"/>
                <span id="saveBtn" class="sq-button sq-button-round" onclick="saveBankInfo(${bindType});">保存</span>
            </div>
        </c:if>

        <%--我司收款账户--%>
        <c:if test="${bindType==4}">
        <div class="fieldset1 tabel_col clearFix">
            <div class="fieldBox col_50">
                <div class="label"><span class="requiredSymbol">*</span>收款银行</div>
                <div class="field">
                    <input class="ui-textbox" id="bankNm" name="bankNm" value="${bank.bankNm}" validate="{required:true,stringMaxLength:80}">
                </div>
            </div>
            <div class="fieldBox col_50">
                <div class="label"><span class="requiredSymbol">*</span>收款账户</div>
                <div class="field">
                    <input type="text" id="accNm" name="accNm" class="ui-textbox" value="${bank.accNm}" validate="{required:true,stringMaxLength:80}"/>
                </div>
            </div>
            <div class="fieldBox col_50">
                <div class="label"><span class="requiredSymbol">*</span>收款账号</div>
                <div class="field">
                    <input type="text" id="accNo" name="accNo" class="ui-textbox" value="${bank.accNo}" validate="{required:true,number:true,stringMaxLength:30}"/>
                </div>
            </div>
            <div class="fieldBox col_100">
                <div class="label">备注</div>
                <div class="field">
                    <textarea name="bankRem" id="bankRem" rows="4" class="" style="width:98%" maxlength="200">${bank.bankRem}</textarea>
                </div>
            </div>
        </div>
        <div class="btnsBox clearFix" style="text-align: center">
            <span id="saveBtn" class="sq-button sq-button-round" onclick="saveBankInfo(${bindType});">保存</span>
        </div>
        </c:if>
    </form>
</div>


<script type="text/javascript">
    var basePath = '<%=path%>';
    var paySchId = $("#paySchId").val();
    var paySchDId = $("#paySchDId").val();
    $(function () {
        $("#addOrUpdBankInfoForm").ligerForm({
            validate: true
        });
    });

    function saveBankInfo(bindType) {
        var form = liger.get("addOrUpdBankInfoForm");
        if (!form.valid()) {
            top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
            return false;
        }
        var reqParams = {};
        reqParams.paySchId = paySchId;
        reqParams.paySchDId = paySchDId;
        reqParams.bindType = bindType;
        var json = [], formData = form.getData();
        if (formData.payAmt != null) {
            formData.payAmt = NumberUtils.multi(formData.payAmt, 100);
        }
        formData.id = $("#bankId").val();
        json.push(formData)
        if (bindType == 1) {
            reqParams.cstBankJSON = JSON.stringify(json);
        } else if (bindType == 2) {
            reqParams.cstBankJSON_1 = JSON.stringify(json);
        } else if (bindType == 3) {
            reqParams.ourComBankJSON_1 = JSON.stringify(json);
        } else if (bindType == 4) {
            reqParams.ourComBankJSON = JSON.stringify(json);
        }else if (bindType == 5) {
            reqParams.cstBankJSON_1 = JSON.stringify(json);
        }

        var wait_dialog;
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: reqParams,
            url: basePath+'/project/prjPrdPaySchBank/batchAdd.do',
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                    $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                    if (bindType == 1) {
                        parent.cstBankGrid.reload();
                    } else if (bindType == 2 || bindType == 5) {
                        parent.cstBankGrid_1.reload();
                    }  else if (bindType == 3) {
                        parent.ourComBankGrid_1.reload();
                    } else if (bindType == 4) {
                        parent.ourComBankGrid.reload();
                    }
                    frameElement.dialog.close();
                } else {
                    $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }
</script>

</body>
</html>

